<template>
  <div style="background-color: white; width: 100%; height: 100%">
    <el-button
      link
      @click="router.push('/ProducManagement/SuppliersQuery')"
      style="margin-left: 10px"
      >‹返回</el-button
    >
    &nbsp;
    <span>|</span>
    &nbsp;
    <span style="font-size: 17px; font-weight: 500; color: green"
      >供应商基本信息</span
    >
    <hr style="background-color: #d3d3d3; height: 1px; border: none" />
    <h3
      style="
        font-size: 15px;
        font-weight: 700;
        margin-left: 50px;
        margin-top: 20px;
      "
    >
      标准信息
    </h3>
    <table
      class="demo-ruleForm"
      :model="form"
      ref="formRef"
      label-width="auto"
      style="max-width: 1000px; margin-left: 180px; margin-top: 20px"
    >
      <tr>
        <td>
          <el-form-item
            label="供应商编码"
            style="margin: 25px"
            prop="resourceNo"
            :readonly="isNo"
            :rules="[ { required: true, message: '必填' },]"
          >
            <el-input
              v-model="form.suppliersNo"
              style="width: 200px"
            ></el-input>
          </el-form-item>
        </td>
        <td>
          <el-form-item
            label="供应商名称"
            style="margin: 25px"
            prop="suppliersName"
           :rules="[ { required: true, message: '必填' },]"
          >
            <el-input
              v-model="form.suppliersName"
              style="width: 200px"
            ></el-input
          ></el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item
            label="供应商区分"
            style="margin: 25px"
            prop="suppliersType"
            :rules="[ { required: true, message: '必填' },]"
          >
            <el-select v-model="form.suppliersType" placeholder="请选择">
              <el-option label="公司" value="公司" />
              <el-option label="个人" value="个人" />
            </el-select>
          </el-form-item>
        </td>
        <td>
          <el-form-item
            label="供应商电话"
            style="margin: 25px"
            prop="suppliersPhone"
          >
            <el-input
              v-model="form.suppliersPhone"
              style="width: 200px"
            ></el-input
          ></el-form-item>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <el-form-item
            label="供应商地址"
            style="margin: 25px"
            prop="suppliersAdder"
          >
            <el-input
              v-model="form.suppliersAdder"
              style="width: 550px"
            ></el-input>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item
            label="所在国家"
            style="margin: 25px"
            prop="countryId"
            :rules="[ { required: true, message: '必填' },]"
          >
            <el-select v-model="form.countryId" placeholder="请选择">
              <el-option label="中国" :value="1" />
            </el-select>
          </el-form-item>
        </td>
        <td>
          <el-form-item
            label="所在城市"
            style="margin: 25px"
            prop="cityId"
            :rules="[ { required: true, message: '必填' },]"
          >
            <el-select v-model="form.cityId" placeholder="请选择">
                <el-option label="北京" :value="1" />
                <el-option label="天津" :value="2" />
                <el-option label="上海" :value="3" />
                <el-option label="广州" :value="4" />
                <el-option label="深圳" :value="5" />
                <el-option label="珠海" :value="6" />
                <el-option label="石家庄" :value="7" />
                <el-option label="苏州" :value="8" />
                <el-option label="杭州" :value="9" />
                <el-option label="南京" :value="10" />
                <el-option label="青岛" :value="11" />
                <el-option label="重庆" :value="12" />
                <el-option label="长沙" :value="13" />
                <el-option label="西安" :value="14" />
                <el-option label="成都" :value="15" />
            </el-select>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item
            label="供应商分类"
            style="margin: 25px"
            prop="supplierClassification"
          >
            <el-select
              v-model="form.supplierClassification"
              placeholder="请选择"
            >
              <el-option label="普通客户" value="普通客户" />
              <el-option label="VIP客户" value="VIP客户" />
            </el-select>
          </el-form-item>
        </td>
        <td>
          <el-form-item
            label="供应商标签"
            style="margin: 25px"
            prop="supplierLabels"
          >
            <el-input
              v-model="form.supplierLabels"
              style="width: 200px"
            ></el-input
          ></el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item
            label="本公司标识"
            style="margin: 25px"
            prop="companyLogo"
            :rules="[{ required: true, message: '必填' }]"
          >
            <el-select v-model="form.companyLogo" placeholder="请选择">
              <el-option label="是" value="是" />
              <el-option label="否" value="否" />
            </el-select>
          </el-form-item>
        </td>
        <td>
          <el-form-item
            label="委外标识"
            style="margin: 25px"
            prop="outsideLabel"
            :rules="[{ required: true, message: '必填' }]"
          >
            <el-select v-model="form.outsideLabel" placeholder="请选择">
              <el-option label="是" :value="1" />
              <el-option label="否" :value="2" />
            </el-select>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item
            label="状态"
            style="margin: 25px"
            prop="suppliersStatus"
            :rules="[{ required: true, message: '必填' }]"
          >
            <el-select v-model="form.suppliersStatus" placeholder="请选择">
              <el-option label="有效" :value="1" />
              <el-option label="无效" :value="2" />
            </el-select>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <el-button type="success" @click="GetAdd">保存</el-button>
          <el-button
                style=" width: 80px"
                v-show="isshow"
                @click="AddSuppliers()"
                >{{ tianjia }}</el-button
              >
        </td>
      </tr>
    </table>
    
  <h2 style="font-size: 17px;font-weight: 500; color: #409EFF; margin-top: 60px; margin-left: 50px; margin-bottom: 10px;" >供应商其他信息</h2>
        <hr style='background-color:#d3d3d3; height:1px; border:none;'>
        <!-- 根据供应商区分 如果是公司显示营业执照 -->
    <el-tabs type="border-card" style="margin-top: 30px;margin-left: 30px" v-show="form.suppliersType == '公司'|| form.suppliersType == ''">
      <!-- 营业执照 -->
      <el-tab-pane v-show="form.suppliersType == '公司'|| form.suppliersType == ''" label="营业执照" >
        <div style="background-color: white;width: 100%;height: 200%;">
    <el-form
    ref="ruleFormRef"
    style="max-width: 600px;margin-left: 180px;margin-top: 20px;"
    :model="ruleForm"
    :rules="rules"
    label-width="auto"
    class="demo-ruleForm"
    :size="formSize"
    status-icon
  >
    <el-form-item label="营业执照号:" prop="businessLicenseNo">
      <el-input v-model="ruleForm.businessLicenseNo" />
    </el-form-item>
    <el-form-item label="法人代表:" prop="representative">
      <el-input v-model="ruleForm.representative" />
    </el-form-item>
    <el-form-item label="公司类型:" prop="enterpriseTypeId">
      <el-select v-model="ruleForm.enterpriseTypeId" placeholder="请选择">
        <el-option label="有限负责公司" :value="1" />
        <el-option label="股份有限负责公司" :value="2" />
        <el-option label="个人独资企业" :value="3" />
        <el-option label="合伙企业" :value="4" />
      </el-select>
    </el-form-item>
    <el-form-item label="经营范围:" prop="businessLicensesRange">
      <el-input v-model="ruleForm.businessLicensesRange" />
    </el-form-item>
    <el-form-item label="成立时间:" prop="businessLicensesDate">
      <el-date-picker
        v-model="ruleForm.businessLicensesDate"
        type="date"
        placeholder="请选择成立日期"
        format="YYYY-MM-DD"
        value-format="YYYY-MM-DD"
      />
    </el-form-item>
    <el-form-item label="状态:" prop="businessLicensesStateser">
      <el-select v-model="ruleForm.businessLicensesStateser" placeholder="请选择">
                <el-option label="有效" :value="1" />
                <el-option label="无效" :value="2" />
            </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="success" @click="AddBusinessLicense()">
        保存
      </el-button>
    </el-form-item>
  </el-form>
   
     
  </div>
      </el-tab-pane>
      <!-- 联系人的信息 -->
      <el-tab-pane label="联系人">
        <div class="demo-collapse">
          <el-collapse accordion> </el-collapse>
        </div>
        <div style="background-color: white; width: 100%; height: 100%">
          <el-button
            type="primary"
            style="float: right; margin-top: -10px; margin-right: 20px"
            @click="dialogFormVisible = true"
            >+新增联系人</el-button
          >

          <div style="margin: 20px">
            <el-table :data="AddContactPersonList" style="width: 100%">
              <el-table-column prop="contactPersonsId" label="序号" />
              <el-table-column prop="contactPersonsName" label="联系人" />
              <el-table-column prop="contactPersonsTell" label=" 联系电话" />
              <el-table-column prop="position" label="联系人岗位" />
              <el-table-column prop="handleTime" label="创建时间" width="180">
                <template #default="{ row }">
                  {{ moment(row.handleTime).format("YYYY-MM-DD HH:mm:ss") }}
                </template>
              </el-table-column>
              <el-table-column prop="handle" label="创建人" width="180" />
              <el-table-column
                prop="contactPersonStatus"
                label="状态"
                width="180"
              >
                <template #default="{ row }">
                  <el-text v-if="row.contactPersonStatus == 1" type="primary"
                    >有效</el-text
                  >
                  <el-text v-else type="danger">无效</el-text>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>

        <!-- 新增 -->
        <el-dialog v-model="dialogFormVisible" title="联系人新增" width="500">
          <el-form
            ref="ruleFormRef"
            style="max-width: 600px"
            :model="ruleForm"
            :rules="rules"
            label-width="auto"
            class="demo-ruleForm"
            :size="formSize"
            status-icon
          >
            <el-form-item label="联系人" prop="contactPersonsName">
              <el-input v-model="ruleForm.contactPersonsName" />
            </el-form-item>
            <el-form-item label="联系电话" prop="contactPersonsTell">
              <el-input v-model="ruleForm.contactPersonsTell" />
            </el-form-item>
            <el-form-item label="联系人岗位" prop="position">
              <el-input v-model="ruleForm.position" />
            </el-form-item>
            <el-form-item label="状态" prop="contactPersonStatus">
              <el-select
                v-model="ruleForm.contactPersonStatus"
                placeholder="请选择"
              >
                <el-option label="有效" :value="1" />
                <el-option label="无效" :value="2" />
              </el-select>
            </el-form-item>
          </el-form>
          <template #footer>
            <div class="dialog-footer">
              <el-button @click="dialogFormVisible = false">取消</el-button>
              <el-button type="primary" @click="AddContactPerson"> 确定 </el-button>
            </div>
          </template>
        </el-dialog>
      </el-tab-pane>
      <!-- 银行信息 -->
      <el-tab-pane label="银行信息">
        <div style="background-color: white;width: 100%;height: 100%;">
   <el-button type="primary" style="float: right;margin-top: -10px;margin-right: 20px;" @click="dialogFormVisible2 =true">+新增银行</el-button>
   
   <div style="margin: 20px;">
     <el-table :data="BankAddList" style="width: 100%">
<el-table-column prop="banksId" label="序号" />
<el-table-column prop="banksNo" label="银行编码"/>
<el-table-column prop="branchNo" label=" 分行编码" />
<el-table-column prop="banksAccount" label="银行账户"/>
<el-table-column prop="handleTime" label="创建时间" width="180">
 <template #default="{row}">
   {{ moment(row.handleTime).format("YYYY-MM-DD HH:mm:ss") }}
 </template>
</el-table-column>
<el-table-column prop="handle" label="创建人" width="180" />
<el-table-column prop="bankStatus" label="状态" width="180">
 <template #default="{row}">
  <el-text v-if="row.bankStatus==1" type="primary">有效</el-text>
  <el-text v-else type="danger">无效</el-text>
 </template>
</el-table-column>
</el-table>

   </div>
 
 </div>

 <!--添加-->
 <el-dialog v-model="dialogFormVisible2" title="银行新增" width="500">
    <el-form
    ref="ruleFormRef"
    style="max-width: 600px"
    :model="ruleForm"
    :rules="rules"
    label-width="auto"
    class="demo-ruleForm"
    :size="formSize"
    status-icon
  >
    <el-form-item label="银行编码" prop="banksNo">
      <el-select v-model="ruleForm.banksNo" placeholder="请选择">
                <el-option label="中国交通银行" value="中国交通银行" />
                <el-option label="交通银行" value="交通银行" />
                <el-option label="中国银行" value="中国银行" />
                <el-option label="中国建设银行" value="中国建设银行" />
                <el-option label="中信银行" value="中信银行" />
                <el-option label="招商银行" value="招商银行" />
                <el-option label="中国工商银行" value="中国工商银行" />

            </el-select>
    </el-form-item>
    <el-form-item label="分行编码" prop="branchNo">
      <el-input v-model="ruleForm.branchNo" />
    </el-form-item>
    <el-form-item label="银行账户" prop="banksAccount">
      <el-input v-model="ruleForm.banksAccount" />
    </el-form-item>
    <el-form-item label="状态" prop="bankStatus">
      <el-select v-model="ruleForm.bankStatus" placeholder="请选择">
                <el-option label="有效" :value="1" />
                <el-option label="无效" :value="2" />
            </el-select>
    </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogFormVisible2 = false">返回</el-button>
        <el-button type="primary" @click="BankAdd">
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>
  
      </el-tab-pane>
    </el-tabs>

    <!-- 如果是个人不显示营业执照 -->
    <el-tabs type="border-card" style="margin-top: 30px;margin-left: 30px" v-show="form.suppliersType == '个人'">
      <!-- 联系人的信息 -->
      <el-tab-pane label="联系人">
        <div class="demo-collapse">
          <el-collapse accordion> </el-collapse>
        </div>
        <div style="background-color: white; width: 100%; height: 100%">
          <el-button
            type="primary"
            style="float: right; margin-top: -10px; margin-right: 20px"
            @click="dialogFormVisible = true"
            >+新增联系人</el-button
          >

          <div style="margin: 20px">
            <el-table :data="AddContactPersonList" style="width: 100%">
              <el-table-column prop="contactPersonsId" label="序号" />
              <el-table-column prop="contactPersonsName" label="联系人" />
              <el-table-column prop="contactPersonsTell" label=" 联系电话" />
              <el-table-column prop="position" label="联系人岗位" />
              <el-table-column prop="handleTime" label="创建时间" width="180">
                <template #default="{ row }">
                  {{ moment(row.handleTime).format("YYYY-MM-DD HH:mm:ss") }}
                </template>
              </el-table-column>
              <el-table-column prop="handle" label="创建人" width="180" />
              <el-table-column
                prop="contactPersonStatus"
                label="状态"
                width="180"
              >
                <template #default="{ row }">
                  <el-text v-if="row.contactPersonStatus == 1" type="primary"
                    >有效</el-text
                  >
                  <el-text v-else type="danger">无效</el-text>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>

        <!-- 新增 -->
        <el-dialog v-model="dialogFormVisible" title="联系人新增" width="500">
          <el-form
            ref="ruleFormRef"
            style="max-width: 600px"
            :model="ruleForm"
            :rules="rules"
            label-width="auto"
            class="demo-ruleForm"
            :size="formSize"
            status-icon
          >
            <el-form-item label="联系人" prop="contactPersonsName">
              <el-input v-model="ruleForm.contactPersonsName" />
            </el-form-item>
            <el-form-item label="联系电话" prop="contactPersonsTell">
              <el-input v-model="ruleForm.contactPersonsTell" />
            </el-form-item>
            <el-form-item label="联系人岗位" prop="position">
              <el-input v-model="ruleForm.position" />
            </el-form-item>
            <el-form-item label="状态" prop="contactPersonStatus">
              <el-select
                v-model="ruleForm.contactPersonStatus"
                placeholder="请选择"
              >
                <el-option label="有效" :value="1" />
                <el-option label="无效" :value="2" />
              </el-select>
            </el-form-item>
          </el-form>
          <template #footer>
            <div class="dialog-footer">
              <el-button @click="dialogFormVisible = false">取消</el-button>
              <el-button type="primary" @click="AddContactPerson"> 确定 </el-button>
            </div>
          </template>
        </el-dialog>
      </el-tab-pane>
      <!-- 银行信息 -->
      <el-tab-pane label="银行信息">
        <div style="background-color: white;width: 100%;height: 100%;">
   <el-button type="primary" style="float: right;margin-top: -10px;margin-right: 20px;" @click="dialogFormVisible2 =true">+新增银行</el-button>
   
   <div style="margin: 20px;">
     <el-table :data="BankAddList" style="width: 100%">
<el-table-column prop="banksId" label="序号" />
<el-table-column prop="banksNo" label="银行编码"/>
<el-table-column prop="branchNo" label=" 分行编码" />
<el-table-column prop="banksAccount" label="银行账户"/>
<el-table-column prop="handleTime" label="创建时间" width="180">
 <template #default="{row}">
   {{ moment(row.handleTime).format("YYYY-MM-DD HH:mm:ss") }}
 </template>
</el-table-column>
<el-table-column prop="handle" label="创建人" width="180" />
<el-table-column prop="bankStatus" label="状态" width="180">
 <template #default="{row}">
  <el-text v-if="row.bankStatus==1" type="primary">有效</el-text>
  <el-text v-else type="danger">无效</el-text>
 </template>
</el-table-column>
</el-table>

   </div>
 
 </div>

 <!--添加-->
 <el-dialog v-model="dialogFormVisible2" title="银行新增" width="500">
    <el-form
    ref="ruleFormRef"
    style="max-width: 600px"
    :model="ruleForm"
    :rules="rules"
    label-width="auto"
    class="demo-ruleForm"
    :size="formSize"
    status-icon
  >
    <el-form-item label="银行编码" prop="banksNo">
      <el-select v-model="ruleForm.banksNo" placeholder="请选择">
                <el-option label="中国交通银行" value="中国交通银行" />
                <el-option label="交通银行" value="交通银行" />
                <el-option label="中国银行" value="中国银行" />
                <el-option label="中国建设银行" value="中国建设银行" />
                <el-option label="中信银行" value="中信银行" />
                <el-option label="招商银行" value="招商银行" />
                <el-option label="中国工商银行" value="中国工商银行" />

            </el-select>
    </el-form-item>
    <el-form-item label="分行编码" prop="branchNo">
      <el-input v-model="ruleForm.branchNo" />
    </el-form-item>
    <el-form-item label="银行账户" prop="banksAccount">
      <el-input v-model="ruleForm.banksAccount" />
    </el-form-item>
    <el-form-item label="状态" prop="bankStatus">
      <el-select v-model="ruleForm.bankStatus" placeholder="请选择">
                <el-option label="有效" :value="1" />
                <el-option label="无效" :value="2" />
            </el-select>
    </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogFormVisible2 = false">返回</el-button>
        <el-button type="primary" @click="BankAdd">
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>
  
      </el-tab-pane>
    </el-tabs>
    
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive, onMounted, readonly } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { useRouter, useRoute } from "vue-router";
import axios from "axios";
const formRef = ref<FormInstance>();
const apiurl = import.meta.env.VITE_APP_API_URL_ProductionAdd;
const router = useRouter();
const route = useRoute();
import type { ComponentSize, FormInstance, FormRules } from "element-plus";
const dialogFormVisible = ref(false);
const dialogFormVisible2 = ref(false);
import moment from "moment";

//获取登录信息
const UserList = ref([]);
const LoadUserJSONData = () => {
  //读出数据
  const value = localStorage.getItem("userInfo");
  //反序列化JSON字符串
  UserList.value = JSON.parse(value);
  UserList.value.forEach((item: any) => {
    form.handle = item.userName;
  });
};



//显示提交按钮
const isshow = ref(false);
//供应商编码是否只读
const isNo = ref(false);
const tianjia = ref("提交");

//点击保存进行下一步操作
const GetAdd = () => {
  if(form.suppliersNo==""){
    return ElMessage.error("请输入完整信息 在进行提交")
  }
  isshow.value = true;
  isNo.value = true;
};


//供应商信息字段
const form = reactive({
  suppliersId: 0,
  suppliersNo: "",
  suppliersName: "",
  suppliersType: "",
  suppliersPhone: "",
  suppliersAdder: "",
  countryId: "",
  cityId: "",
  supplierClassification: "",
  supplierLabels: "",
  companyLogo: "",
  outsideLabel: "",
  suppliersStatus: "",
  handle: "",
  handleContext: "添加",
  pid: 0,
  isDelete: 0,
});

//供应商管理添加
const AddSuppliers = () => {
  const data={

      suppliersNo: form.suppliersNo,
      suppliersName: form.suppliersName,
      suppliersType: form.suppliersType,
      suppliersPhone: form.suppliersPhone,
      suppliersAdder: form.suppliersAdder,
      countryId: form.countryId,
      cityId: form.cityId,
      supplierClassification: form.supplierClassification,
      supplierLabels: form.supplierLabels,
      companyLogo: form.companyLogo,
      outsideLabel: form.outsideLabel,
      suppliersStatus: form.suppliersStatus,
      handle: form.handle,
      handleContext: form.handleContext,
      pid: form.pid,
      isDelete: form.isDelete,
      businessLicensesData:AddBusinessLicensesList.value,
      contactPersonsData: AddContactPersonList.value,
      banksData:BankAddList.value,
  }
  console.log(data);  
  axios
    .post(apiurl + "/api/ProducManagement/AddSupplier",data)
    .then((res) => {
      console.log(res.data);
      ElMessage.success("添加成功");
    });
};


//字段
interface RuleForm {
 suppliersId:number
  //营业执照信息字段
  businessLicenseId: number
  businessLicenseNo: string
  representative: string;
  enterpriseTypeId:string
  businessLicensesRange: string;
  businessLicensesDate:string;
  businessLicensesStateser:string;
  //联系人信息字段
  contactPersonsId: number;
  contactPersonsName: string;
  contactPersonsTell: string;
  position: string;
  contactPersonStatus: string;
  //银行信息字段
  banksId: number,
  banksNo: string
  branchNo: string
  banksAccount: string
  bankStatus: string
}

const formSize = ref<ComponentSize>("default");
const ruleFormRef = ref<FormInstance>();
const ruleForm = reactive<RuleForm>({
  suppliersId:0,
  //营业执照信息字段
  businessLicenseId: 0,
  businessLicenseNo: '',
  representative: '',
  enterpriseTypeId:'',
  businessLicensesRange: '',
  businessLicensesDate: '',
  businessLicensesStateser: '',
  //联系人信息字段
  contactPersonsId: 0,
  contactPersonsName: "",
  contactPersonsTell: "",
  position: "",
  contactPersonStatus: "",
  //银行信息字段
  banksId: 0,
  banksNo: '',
  branchNo: '',
  banksAccount:'',
  bankStatus: '',
});

//表单验证
const rules = reactive<FormRules<RuleForm>>({
  contactPersonsName: [
    { required: true, message: "请输入联系人", trigger: "blur" },
  ],
  contactPersonsTell: [
    { required: true, message: "请输入联系电话", trigger: "blur" },
  ],
  position: [{ required: true, message: "请输入联系人岗位", trigger: "blur" }],
  banksNo: [
    { required: true, message: '请选择银行编码', trigger: 'blur' },
  ],
  branchNo: [
    { required: true, message: '请输入分行名称', trigger: 'blur' },
  ],
  banksAccount: [
    { required: true, message: '请输入银行账户', trigger: 'blur' },
  ],
  businessLicenseNo: [
    { required: true, message: '请输入营业执照', trigger: 'blur' }
  ],
  representative: [
    { required: true, message: '请输入法人代表', trigger: 'blur' }
  ],
  enterpriseTypeId: [
    { required: true, message: '请输入公司类型', trigger: 'blur' }
  ],
  businessLicensesDate: [
    { required: true, message: '请选择成立时间', trigger: 'blur' }
  ],
});



//定义一个数组来暂时存储营业执照的添加信息
const AddBusinessLicensesList:any = ref([]);
const IdNo = ref(0);
const AddBusinessLicense=()=>{
    IdNo.value= IdNo.value+1;
    const data={
      businessLicenseId: IdNo.value,
      businessLicenseNo: ruleForm.businessLicenseNo,
      representative: ruleForm.representative,
      enterpriseTypeId: ruleForm.enterpriseTypeId,
      businessLicensesRange: ruleForm.businessLicensesRange,
      businessLicensesDate: ruleForm.businessLicensesDate,
      businessLicensesStateser: ruleForm.businessLicensesStateser,
      suppliersId:form.suppliersId,
      handle: form.handle,
      handleContext: form.handleContext,
      pid: form.pid,
      isDelete: false
    };
    AddBusinessLicensesList.value.push(data);
    console.log(AddBusinessLicensesList.value,"456");
}


//定义一个数组来暂时存储联系人的添加信息
const AddContactPersonList:any = ref([]);
const ContactPersonIdNo = ref(0);
const AddContactPerson=()=>{
  ContactPersonIdNo.value=ContactPersonIdNo.value+1;
    const data={
      contactPersonsId: ContactPersonIdNo.value,
      contactPersonsName: ruleForm.contactPersonsName,
      contactPersonsTell: ruleForm.contactPersonsTell,
      position: ruleForm.position,
      contactPersonStatus: ruleForm.contactPersonStatus,
      suppliersId:form.suppliersId,
      handle: form.handle,
      handleContext: form.handleContext,
      pid: form.pid,
      isDelete: 0
    };
    dialogFormVisible.value = false;
    AddContactPersonList.value.push(data);
    console.log(AddContactPersonList.value,"456");
}

//定义一个数组来暂时存储银行的添加信息
const BankAddList:any = ref([]);
const BankIdNo = ref(0);
const BankAdd=()=>{
  BankIdNo.value=BankIdNo.value+1;
    const data={
      banksId: BankIdNo.value,
      banksNo: ruleForm.contactPersonsName,
      branchNo: ruleForm.contactPersonsTell,
      banksAccount: ruleForm.position,
      bankStatus: ruleForm.contactPersonStatus,
      suppliersId:form.suppliersId,
      handle: form.handle,
      handleContext: form.handleContext,
      pid: form.pid,
      isDelete: 0
    };
    dialogFormVisible2.value = false;
    BankAddList.value.push(data);
    console.log(BankAddList.value,"456");
}


//钩子函数
onMounted(() => {
  LoadUserJSONData()
});

</script>
